package com.dayuanit.response;

public class ExResponse<T> {


    /**
     * 业务码
     */
    private Integer code;

    /**
     * 信息描述
     */
    private String msg;


    /**
     * 实体
     */
    private T data;


    private Long count;


    public ExResponse() {

    }

    public ExResponse(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ExResponse(Integer code, String msg, T info) {
        this.code = code;
        this.msg = msg;
        this.data = info;
    }

    public ExResponse(Integer code, String msg, T info, Long count) {
        this.code = code;
        this.msg = msg;
        this.data = info;
        this.count = count;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }




    public static ExResponse buildSuccessWithoutInfo() {
        return new ExResponse(0,"操作成功");
    }

    public static ExResponse buildSuccess(Object info) {
        return new ExResponse(0,"操作成功",info);
    }

    public static ExResponse buildSuccessList(Object info, Long count) {
        return new ExResponse(0, "查询成功", info, count);
    }

    public static ExResponse buildFailWithoutInfo(Integer code, String msg) {
        return new ExResponse(code,msg);
    }

    public static ExResponse buildSystemError() {
        return new ExResponse(1,"system error");
    }
}
